package com.joinval.modules.sys.controller;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.joinval.modules.sys.entity.SysUserDetail;
import com.joinval.modules.sys.service.SysUserDetailService;
import com.joinval.common.utils.PageUtils;
import com.joinval.common.utils.Result;



/**
 * 用户详情
 *
 * @author xu
 * @email -
 * @date 2020-08-25 10:32:42
 */
@Api(description = "系统用户详情控制器")
@RestController
@RequestMapping("sys/sysUserDetail")
public class SysUserDetailController {

    @Autowired
    private SysUserDetailService sysUserDetailService;

    /**
     * 列表
     */
    @ApiOperation(value="列表")
    @GetMapping("/list")
    public Result list(@RequestParam Map<String, Object> params){
        PageUtils page = sysUserDetailService.queryPage(params);
        return Result.ok().data(page);
    }


    /**
     * 信息
     */
    @ApiOperation(value="信息")
    @GetMapping("/info/{sysUserDetailId}")
    public Result info(@PathVariable("sysUserDetailId") Long sysUserDetailId){
		SysUserDetail sysUserDetail = sysUserDetailService.getById(sysUserDetailId);
        return Result.ok().data(sysUserDetail);
    }

    /**
     * 新增
     */
    @ApiOperation(value="新增")
    @PostMapping("/save")
    public Result save(@RequestBody SysUserDetail sysUserDetail){
        Boolean result = sysUserDetailService.save(sysUserDetail);
        return result?Result.ok():Result.error("保存失败");
    }

    /**
     * 修改
     */
    @ApiOperation(value="修改")
    @PostMapping("/update")
    public Result update(@RequestBody SysUserDetail sysUserDetail){
        Boolean result = sysUserDetailService.updateById(sysUserDetail);
        return result?Result.ok():Result.error("更新失败");
    }

    /**
     * 删除
     */
    @ApiOperation(value="删除")
    @PostMapping("/delete/{sysUserDetailId}")
    public Result delete(@PathVariable("sysUserDetailId") Long sysUserDetailId){
		Boolean result = sysUserDetailService.removeById(sysUserDetailId);
        return result?Result.ok():Result.error("删除失败");
    }

}
